package com.bytedance.ttnet.hostmonitor;

import android.os.Parcel;
import android.os.Parcelable;

import com.google.gson.Gson;

public class HostStatus implements Parcelable {
    public static final Parcelable.Creator CREATOR = new g();

    private ConnectionType connectionType;
    private String host;
    private int port;
    private ConnectionType previousConnectionType;
    private boolean previousReachable;
    private boolean reachable;

    public HostStatus() {

    }

    private HostStatus(Parcel arg4) {
        boolean v1 = true;
        this.host = arg4.readString();
        this.port = arg4.readInt();
        boolean v0 = arg4.readInt() == 1 ? true : false;
        this.previousReachable = v0;
        if (arg4.readInt() != 1) {
            v1 = false;
        }

        this.reachable = v1;
        this.connectionType = ConnectionType.values()[arg4.readInt()];
        this.previousConnectionType = ConnectionType.values()[arg4.readInt()];
    }

    HostStatus(Parcel arg1, g arg2) {
        this(arg1);
    }

    public boolean connectionTypeChanged() {
        boolean v0 = this.previousConnectionType != this.connectionType ? true : false;
        return v0;
    }

    public int describeContents() {
        return 0;
    }

    public ConnectionType getConnectionType() {
        return this.connectionType;
    }

    public HostStatus setConnectionType(ConnectionType arg1) {
        this.connectionType = arg1;
        return this;
    }

    public String getHost() {
        return this.host;
    }

    public HostStatus setHost(String arg1) {
        this.host = arg1;
        return this;
    }

    public int getPort() {
        return this.port;
    }

    public HostStatus setPort(int arg1) {
        this.port = arg1;
        return this;
    }

    public ConnectionType getPreviousConnectionType() {
        return this.previousConnectionType;
    }

    public HostStatus setPreviousConnectionType(ConnectionType arg1) {
        this.previousConnectionType = arg1;
        return this;
    }

    public boolean isPreviousReachable() {
        return this.previousReachable;
    }

    public HostStatus setPreviousReachable(boolean arg1) {
        this.previousReachable = arg1;
        return this;
    }

    public boolean isReachable() {
        return this.reachable;
    }

    public HostStatus setReachable(boolean arg1) {
        this.reachable = arg1;
        return this;
    }

    public boolean reachabilityChanged() {
        boolean v0 = this.previousReachable != this.reachable ? true : false;
        return v0;
    }

    public String toString() {
        return new Gson().toJson(this);
    }

    public void writeToParcel(Parcel arg4, int arg5) {
        int v1 = 1;
        arg4.writeString(this.host);
        arg4.writeInt(this.port);
        int v0 = this.previousReachable ? 1 : 0;
        arg4.writeInt(v0);
        if (!this.reachable) {
            v1 = 0;
        }

        arg4.writeInt(v1);
        arg4.writeInt(this.connectionType.ordinal());
        arg4.writeInt(this.previousConnectionType.ordinal());
    }
}

